package com.controller;

import com.model.LOG;
import com.server.MylogService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "1228作业测试")
@RestController
@RequestMapping("/mylog")


public class logController {

    @Autowired
    private MylogService mylogService;

    @RequestMapping(value = "/addLog", method = RequestMethod.GET)
    public int addLog(LOG myLog){
        System.out.println("进入日志添加方法");
        return mylogService.addLog(myLog);
    }
    @RequestMapping(value = "/getLog", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public LOG getLog(int IPaddress){
        System.out.println("进入根据主键查找日志信息, 主键为: " + IPaddress);
        return mylogService.getLog(IPaddress);
    }

    @RequestMapping(value = "/updateUser", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public int updateMylog(LOG myLog){
        System.out.println("进入日志修改方法, 修改的主键为: " + myLog.getIPaddress());
        return mylogService.updateMylog(myLog);
    }

    @RequestMapping(value = "/deleteLog", method = RequestMethod.GET)
    public int deleteMylog(int IPaddress){
        System.out.println("进入删除日志信息, 主键为: " + IPaddress);
        return mylogService.deleteMylog(IPaddress);
    }

    @RequestMapping(value = "/getAll", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public List<LOG> getAllMylogs(LOG myLog){
        System.out.println("进入日志查询方法");
        return mylogService.getAllMylogs(myLog);
    }

    @RequestMapping(value = "/getIdAndTime", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public LOG getIdAndTime(int IPaddress) {
        System.out.println("进入查询用户ID以及操作时间方法");
        return mylogService.getIdAndTime(IPaddress);
    }
}
